<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ajax请求</title>
</head>
<body>
    <div>
        <table>
            <thead>
                <tr>
                    <th>宠物名称</th>
                    <th>宠物年龄</th>
                </tr>
            </thead>
            <tbody id="content">

            </tbody>
        </table>
    </div>

    <script src="/lk/plugins/jquery/jquery.min.js"></script>
    <script>
        $.ajax({
            type:'get',
            url:'/lk/json/index',
            success:function (result) {
                if(result.code==200){
                    console.log(result.data);
                    let arr=result.data;//数组
                    let str="";
                    for (let i=0;i<arr.length;i++) {
                        str+="<tr>";
                        str+="<td>";
                        str+=arr[i].name;
                        str+="</td>";

                        str+="<td>";
                        str+=arr[i].age;
                        str+="</td>";
                        str+="</tr>"
                    }

                    $("#content").append(str);
                }
            }
        })
    </script>
</body>
</html>